Skip to content

fix: deduplicate DOM query and add null guard in renderThemeSelectIcon#5896

Open
AdityaM-IITH wants to merge 1 commit intosugarlabs:masterfrom
AdityaM-IITH:fix-theme-select-icon-null-guard
Open

fix: deduplicate DOM query and add null guard in renderThemeSelectIcon#5896
AdityaM-IITH wants to merge 1 commit intosugarlabs:masterfrom
AdityaM-IITH:fix-theme-select-icon-null-guard

Conversation

@AdityaM-IITH
Copy link
Contributor

The renderThemeSelectIcon method queries "themeSelectIcon" twice
using two different methods (document.getElementById and docById),
and accesses .innerHTML without verifying the element exists.

Changes:

  • Query element once using docById (consistent with codebase style)
  • Add early null guard to prevent TypeError if element is absent
  • Remove redundant themeList variable

No behavior change when element is present.

@github-actions
Copy link
Contributor

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Failed Tests:

palette.test.js
logo.test.js
logoconstants.test.js

@vanshika2720
Copy link
Contributor

@AdityaM-IITH pull updated master and solve these jest failures

@AdityaM-IITH AdityaM-IITH force-pushed the fix-theme-select-icon-null-guard branch from 1a63e85 to 4321803 Compare February 24, 2026 17:57
@AdityaM-IITH
Copy link
Contributor Author

Rebased on latest master (83c5c8d). All 117 test suites passing locally, including palette.test.js, logo.test.js, and logoconstants.test.js. The 3 previously failing tests were fixed upstream by the recent test file updates.

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants